//调用微信JS api 支付
	


_phpwork_wechat = {
	callpay:function(json,callBack){
		if (typeof WeixinJSBridge == "undefined"){
		    if( document.addEventListener ){
		        document.addEventListener('WeixinJSBridgeReady', this.jsApiCall, false);
		    }else if (document.attachEvent){
		        document.attachEvent('WeixinJSBridgeReady', this.jsApiCall); 
		        document.attachEvent('onWeixinJSBridgeReady', this.jsApiCall);
		    }
		}else{
		    this.jsApiCall(json,callBack);
		}		
	},
	jsApiCall:function(json,callBack){
		WeixinJSBridge.invoke(
			'getBrandWCPayRequest',
			json,
			function(res){
				//WeixinJSBridge.log(res.err_msg);
				//alert(res.err_code+res.err_desc+res.err_msg);
                //if(res.err_msg == "get_brand_wcpay_request:ok" ) {
                    // 使用以上方式判断前端返回,微信团队郑重提示：
                    // res.err_msg将在用户支付成功后返回
                    // ok，但并不保证它绝对可靠。
                    //alert('支付成功');
					callBack(res);
                //}
			}
		);
	},
	
	// {"appId":"wxaab9987f54371a6d","timeStamp":"1596892509","nonceStr":"5f2ea55db7e3a","package":"prepay_id=wx082115096919326e676c7821b6d2850000","signType":"MD5","paySign":"96BD865275596EC58BAD5EF6BF6863D9"}
	pay:function(parameter,callBack){
		$.post( "index.php?s=api/wechat/prepay",parameter, function(data){
			_phpwork_wechat.callpay(data , callBack);
		},'json');
	}
}
